#include<stdio.h>

int binary_search(int m[],int key,int low,int high)
{
    int mid=(low+high)/2;
    if(low>high)    return -1;
    if(key==m[mid])   return mid;
    else if(key<m[mid])  return binary_search(m,key,low,mid-1);
    else                 return binary_search(m,key,mid+1,high);
}
int main()
{
    int n,x,len,out;
    printf("请输入查找模型数据大小：");
    scanf("%d",&n);
    printf("请输入查找模型数据样本：");
    int array[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&array[i]);
    }
    printf("请输入需要查找的数据:");
    scanf("%d",&x);
    len=sizeof(array)/sizeof(array[0])-1;
    out=binary_search(array,x,0,len);
    printf("找到数据,位置为%d",out);
}